#ifndef _WDS_PLAYER_H_
#define _WDS_PLAYER_H_


#include "wds_lifeobject.h"
#include "wds_pickup.h"

#include "input/joystick.h"
#include "ui/ui_progress.h"

class WDSGame;
class WDSGun;

class WDSPlayer : public WDSLifeObject , public input::JoystickListener 
{

public:

	struct Shield
	{	
		Shield();
		void					Tick(float dt);
		void					Render(	const math::Vec2& Offset,
										const math::Vec2& Pos,
										float Scale);

		void					Activate();
		bool					IsActivating()const;

		float					m_Counter;
		ui::UISprite			m_Sprite;		
		float					m_Rotation;
		math::Counter			m_BlinkCounter;
			
	};


	struct MoveSpeedBonus		
	{
		bool	m_IsActivate;
		float	m_CurrentMoveBonus;
		bool	m_IsGoingUp;
		float	m_Counter;

		MoveSpeedBonus() :	m_IsActivate(false),
						m_IsGoingUp(false),
						m_CurrentMoveBonus(0.0f),
						m_Counter(0)
		{}


		void	Activate();
		float	Tick(float dt);		

	};

	struct GunSpeedBonus		
	{
		bool	m_IsActivate;
		float	m_Bonus;		
		float	m_Counter;

		GunSpeedBonus() :	m_IsActivate(false),						
						m_Bonus(0.0f),
						m_Counter(0)
		{}


		void	Activate();
		float	Tick(float dt);	

	};


	struct PlayerUI
	{
		PlayerUI();
		~PlayerUI();

		void				Init(WDSPlayer* pPlayer);
		void				Render(float Scale);
		void				Tick(float dt, WDSPlayer* pPlayer);

		ui::UISprite		m_Frame;		
		ui::UIProgress*		m_pUILifeHeart;		
		
	};


	struct LaserSight
	{
		LaserSight();
		void			Render(WDSPlayer* pPlayer, const math::Vec2& Offset, float Scale);		

		ui::UISprite	m_Sprite;
		
	};	


	struct Skill
	{

		Skill();

		float m_FastLoader; 		
		float m_FastShot;
		float m_MoveSpeed;
		float m_Reflex;
		float m_ExtraAmmo;		
		float m_BonusMagnet;
		float m_Regeneration;	
		
	};


	WDSPlayer();
	~WDSPlayer();

	virtual void						Render(const math::Vec2& Offset,float Scale);	
	virtual void						OnDie(){};	
	virtual void						GotDamaged(float Amount,WDSBullet* pBullet, bool Force);
	
	void								RenderShadow(const math::Vec2& Offset,float Scale);
	void								RenderUI(float Scale);
	void								Tick(float World_dt, float dt, const math::Vec2& Offset, float Scale);

	void								OnMouseMove(const math::Vec2& From, const math::Vec2& To);
	void								OnMouseDown(const math::Vec2& Pos);
	void								OnMouseUp(const math::Vec2& Pos);
	void								OnJoystickTilt(const math::Vec3& AxisState);
	void								OnMOGAMotionEvent(float X,float Y);
	void								SetGame(WDSGame* pGame, const math::Vec2& MinBoundary, const math::Vec2& MaxBoundary); 
	const math::Vec2&					GetMousePos() const { return m_MousePos; };
	WDSPlayer::Skill*					GetSkill() { return &m_Skill; };
	bool								GetIsOnlyDefaultGun() const { return true; };

protected: 

	void								GotPickup(WDSPickup::PICKUP_TYPES PickupType);
	void								GotPickupGun(WDSPickup::PICKUP_TYPES PickupTypeGun);
	void								CheckSurrounding(const math::Vec2& Offset);
	
	
	WDSGame*							m_pGame;
	WDSGun*								m_pGun;
	math::Vec2							m_MousePos;	
	bool								m_IsShooting;

	WDSPlayer::Shield					m_Shield;
	MoveSpeedBonus						m_BonusMoveSpeed;
	GunSpeedBonus						m_BonusGunSpeed;
	float								m_Speed;
	float								m_GetHitIndicatorDelay;
	PlayerUI							m_UI;
	LaserSight*							m_pLaserSight;
	WDSPlayer::Skill					m_Skill;

};


#endif